package com.android.lovely.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import android.view.WindowManager
import android.view.animation.Animation
import android.view.animation.RotateAnimation
import com.android.lovely.R
import com.android.lovely.databinding.DialogLoadingBinding

/**
 *
 * @author why
 * @date 2025/3/7 14:13
 */
class CenterLoadingDialog (context: Context) : Dialog(context) {

    private var mBinding: DialogLoadingBinding

    init {
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        mBinding = DialogLoadingBinding.inflate(LayoutInflater.from(context))
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(mBinding.root)
//        canCancel(true)
    }

    override fun onStart() {
        super.onStart()
        window?.apply {
            setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT)
            setBackgroundDrawableResource(android.R.color.transparent)
            addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            decorView.systemUiVisibility =
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            navigationBarColor = context.getColor(android.R.color.transparent)
        }
    }

    fun canCancel(cancel: Boolean) {
        setCancelable(cancel)
        setCanceledOnTouchOutside(cancel)
    }


    override fun dismiss() {
        super.dismiss()
    }

}
